<template>
  <div>
    <h1>这是首页</h1>
    <router-link to="/news">到新闻页</router-link>
    <hr>
    <button @click="add_num(5)">+</button>
    <button @click="add_num_async(200)">异步+</button>
    {{ num }}
    <button @click="reduce_num(10)">-</button>
  </div>
</template>

<script>
import { mapState, mapMutations, mapActions } from 'vuex'
export default {
  name: 'Home',
  methods: {
    ...mapMutations(['add_num', 'reduce_num']),
    ...mapActions(['add_num_async'])
  },
  computed: {
    ...mapState(['num'])
  }
}
</script>

<style lang="scss" scoped>

</style>
